package cn.tedu.store.controller;

import cn.tedu.store.util.AlipayConfig;
import cn.tedu.store.util.PayUtil;
import cn.tedu.store.util.ResponseResult;
import com.alipay.api.AlipayApiException;
import com.alipay.api.internal.util.AlipaySignature;
import org.springframework.http.HttpRequest;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;
import java.io.UnsupportedEncodingException;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;

/**
 * 支付宝支付控制类
 */
@RestController
@RequestMapping("/alipay")
public class AlipayController extends BaseController {
    /**
     * 付款
     * @param outTradeNo 订单号
     * @param totalAmount 订单总价
     * @param subject 商品主题
     * @param body 描述
     * @return
     */
    @RequestMapping("/topay")
    public ResponseResult<Void> alipay(@RequestParam("out_trade_no")String outTradeNo,
    @RequestParam("total_amount")String totalAmount,@RequestParam("subject")String subject,@RequestParam("body")String body){
        String data = PayUtil.alipay(outTradeNo,totalAmount,subject,body);
        return new ResponseResult<>(SUCCESS,data);
    }



}
